<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
echo "<response>";

include("sqlconnect.php");
include("sqlgenerator.php");
include("storeticket.php");

$debug = false;
$ticket_no = $_GET['ticket_no'];

db_connect();

// Query the agent details from the agent code
$query = get_ticket($ticket_no);
if ($debug) {
    echo '<debug>';
    echo 'Query: ' . $query;
    echo '</debug>';
}
$result = db_query($query);

if ($row = mysql_fetch_array($result)) {
    echo '<ticket>';
    try {
        echo '<level>'.$row['level'].'</level>';
        echo '<ticket_no>'.$row['ticket_no'].'</ticket_no>';
        echo '<parent_ticket_no>'.$row['parent_ticket_no'].'</parent_ticket_no>';
        echo '<max_coupon_value>'.$row['max_coupon_value'].'</max_coupon_value>';
        echo '<value>'.$row['value'].'</value>';
        echo '</ticket>';
    } catch (Exception $e) {
        echo '</ticket>';
        echo "<result>Error</result>";
        echo "</response>";
        exit;
    }
    print_all_tickets_below($row['ticket_no']);
}

echo "<result>Success</result>";
echo "</response>";


?>